package com.zrrd.spring_01.factory;

import com.zrrd.spring_01.mapper.OrderDao;
import com.zrrd.spring_01.mapper.impl.OrderDaoImpl;
import org.springframework.beans.factory.FactoryBean;

/**
 * @author WanJl
 * @version 1.0
 * @title OrderDaoFactory03
 * @description 通过FactoryBean来创建和注入Bean
 * @create 2024/10/24
 */
public class OrderDaoFactory03 implements FactoryBean<OrderDao> {
    /**
     * 替换原始的实例工厂来创建对象的方法
     * @return
     * @throws Exception
     */
    @Override
    public OrderDao getObject() throws Exception {
        System.out.println("通过实现FactoryBean的方式来创建和注入Bean");
        return new OrderDaoImpl();
    }

    /**
     * 指定这个Bean的类型  XXX.class
     * @return
     */
    @Override
    public Class<?> getObjectType() {
        return OrderDao.class;
    }
}
